public class Text {




    public  static void TextException(int a){
        if(a == 0){
            throw new ArithmeticException("a传值有问题");
        }
    }

    public static void main(String[] args) {
        TextException(0);
    }

    public static void main9(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        StringBuffer stringBuffer = new StringBuffer();

    }

    public static void main8(String[] args) {
        String str = "    hello    world    ";
        str = str.trim();
        System.out.println(str.toString()); //hello    world
    }

    public static void main7(String[] args) {
        String str = "helloworld";
        str = str.substring(2);
        System.out.println(str.toString());// lloworld
        str = str.substring(2,4);
        System.out.println(str.toString());// ow
    }

    public static void main6(String[] args) {
        String str = " I_am_a_teacher";
        String[] str1 = str.split("_");
        System.out.println(str.toString()); // I_am_a_teacher
        for(String s : str1){
            System.out.print(s.toString() + " "); // I am a teacher
        }
        System.out.println();
    }

    public static void main5(String[] args) {
        String str = "hello";
        str = str.replace('h','b');
        str = str.replace("ll","s");
        System.out.println(str.toString()); //bello
    }

    public static void main4(String[] args) {
        String str = "hello";
        char[] ch = str.toCharArray();

        for(char ch1 : ch){
            System.out.print(ch1 + " "); // h e l l o
        }
        System.out.println();

        String str1 = new String(ch);
        System.out.println(str1.toString()); //hello
    }

    public static void main3(String[] args) {
        String str = "hello";
        String str1 = "HELLO";

        str = str.toUpperCase();// HELLO  小写转大写
        str1 = str1.toLowerCase();// hello 大写转小写

        System.out.println(str);
        System.out.println(str1);

    }
    public static void main2(String[] args) {
        String str = String.valueOf("abc");// abc
        String str1 = String.valueOf(1); // 1
        String str2 = String.valueOf(19); // 19

        System.out.println(str.toString());
        System.out.println(str1.toString());
        System.out.println(str2.toString());
    }
    public static void main1(String[] args) {

        String str = "Hello";
        char ch = str.charAt(0); // 输出H

        System.out.println(ch);

        int i = str.indexOf('l'); // 2
        System.out.println(i);

        int i1 = str.indexOf('l',4); // -1 找不到就返回-1
        int i2 = str.indexOf('l',3); // 3
        int i3 = str.indexOf("ll"); // 2
        int i4 = str.indexOf("ll",3); // -1
        System.out.println(i1);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println(i4);

        System.out.println("=========================");

        System.out.println(str.toString());
        int i5 = str.lastIndexOf('l'); // 3
        int i6 = str.lastIndexOf('l',3); // 3
        int i7 = str.lastIndexOf("ll"); // 2
        int i8 = str.lastIndexOf("ll",2); // 2
        System.out.println(i5);
        System.out.println(i6);
        System.out.println(i7);
        System.out.println(i8);
    }
}
